package com.company.project.search;

import java.io.IOException;

public class Http {

  public static void main (String[] args) throws InterruptedException, IOException {

    /*WebDriver driver = new FirefoxDriver();
    //要抓取的网页
    driver.get("https://s.wanfangdata.com.cn/paper?q=www&p=2");

    //等待页面动态加载完毕
    Thread.sleep(10000);*/

   /* WebDriver driver = new RemoteWebDriver("http://127.0.0.1:10025", DesiredCapabilities.phantomjs());
    driver.get("https://s.wanfangdata.com.cn/paper?q=www&p=2");*/

   /* Connection pageConn = Jsoup.connect("https://www.sciencedirect.com/search?authors=&cid=&issue=&page=&pub=&qs=aa&volume=");
    pageConn.get();
    System.out.println(pageConn.get().toString());*/



    //String s_iso88591 = newString(好“”.getBytes(“UTF-8”),“ISO8859-1”)
   /* String str = "Periodical\u0012\u0004\b\u0001\u0010\u0001\u0012\u0004\b\u0006\u0010\u0001\u001ANChlQZXJpb2RpY2FsQ0hJTmV3UzIwMjExMDI2EhF4ZHRzcWJqczIwMDIwMzAyMhoIcGhheHlvZTE%3Dª\u0006Â\u000B\n" +
            "\u0011xdtsqbjs200203022\u0012=å\u009Fºäº\u008E<span class='highlight'>WWW</span>ç\u009A\u0084å\u009B¾å\u0083\u008Fæ£\u0080ç´¢æ\u008A\u0080æ\u009C¯\u0012C<span class='highlight'>WWW</span>-Based Image Retrieval Techniques\u001A\u0006ç\u008E\u008Bæ¬£*\u000Ba0028312030B!ä¸\u00ADå\u009B½ç§\u0091å\u00AD¦é\u0099¢æ\u0096\u0087ç\u008C®æ\u0083\u0085æ\u008A¥ä¸\u00ADå¿\u0083R/ä¸\u00ADå\u009B½ç§\u0091å\u00AD¦é\u0099¢æ\u0096\u0087ç\u008C®æ\u0083\u0085æ\u008A¥ä¸\u00ADå¿\u0083 å\u008C\u0097äº¬ 100080b\u0007G354.49b\u0007TP391.4\u0082\u0001\få\u009B¾å\u0083\u008Fæ£\u0080ç´¢\u0082\u0001\u0012å\u009Fºäº\u008Eå\u0086\u0085å®¹æ£\u0080ç´¢\u0082\u0001\"<span class='highlight'>WWW</span>¢\u0001Ù\u0002å\u009C¨é\u0098\u0090é\u0087\u008A<span class='highlight'>WWW</span>å\u009B¾å\u0083\u008Fä¿¡æ\u0081¯æ£\u0080ç´¢å\u009Fºæ\u009C¬å\u008E\u009Fç\u0090\u0086ç\u009A\u0084å\u009Fºç¡\u0080ä¸\u008Aï¼\u008Cç\u009D\u0080é\u0087\u008Dä»\u008Bç»\u008Då¹¶è¯\u0084ä»·äº\u0086ç\u009B®å\u0089\u008Då\u009B¾å\u0083\u008Fæ£\u0080ç´¢é¢\u0086å\u009F\u009Fä¸»è¦\u0081ç\u009A\u0084æ£\u0080ç´¢æ\u008A\u0080æ\u009C¯ï¼\u008Cå¹¶å\u0088\u0097ä¸¾äº\u0086å\u0087 ç§\u008Dè¾\u0083ä¸ºå\u0085\u0088è¿\u009Bç\u009A\u0084å\u009B¾å\u0083\u008Fæ£\u0080ç´¢demoç³»ç»\u009Fï¼\u008Cæ\u009C\u0080å\u0090\u008Eå¯¹ä¸\u0080äº\u009Bå\u0088¶çº¦å\u009Fºäº\u008E<span class='highlight'>WWW</span>å\u009B¾å\u0083\u008Fæ£\u0080ç´¢æ\u008A\u0080æ\u009C¯å\u008F\u0091å±\u0095ç\u009A\u0084ç\u0093¶é¢\u0088é\u0097®é¢\u0098è¿\u009Bè¡\u008Cäº\u0086ç®\u0080è¦\u0081ç\u009A\u0084æ\u008E¢è®¨ã\u0080\u0082¨\u0001\u0014²\u0001\bxdtsqbjsÂ\u0001\u0018ç\u008E°ä»£å\u009B¾ä¹¦æ\u0083\u0085æ\u008A¥æ\u008A\u0080æ\u009C¯Â\u00011NEW TECHNOLOGY OF LIBRARY AND INFORMATION SERVICEÊ\u0001\u0002WFÊ\u0001\u0005ISTICø\u0001\u0001\u0080\u0002\u0001\u0088\u0002Ò\u000F\u0092\u0002\u00013ª\u0002\u00014º\u0002\u0003PKUº\u0002\u0003NJUº\u0002\u0005ISTICÂ\u0002$xdtsqbjs/xdts2002/0203pdf/020322.pdfÊ\u0002$10.3969/j.issn.1003-3513.2002.03.022Ò\u0002(ç\u008E\u008Bæ¬£:ä¸\u00ADå\u009B½ç§\u0091å\u00AD¦é\u0099¢æ\u0096\u0087ç\u008C®æ\u0083\u0085æ\u008A¥ä¸\u00ADå¿\u0083Ú\u00023ISTIC:,t0zm64PbepY4qmpJXEcMwUR/j1Vmrg0qBHEmjVIJD9g=â\u0002\u0003chiê\u0002\t1003-3513\u0080\u0003Ú\u0002\u0090\u0003\u0014ª\u0003\u0007Regular²\u0003\n" +
            "Periodicalº\u0003\u0002WF\"\u0006ç\u008E\u008Bæ¬£J7ä¸\u00ADå\u009B½ç§\u0091å\u00AD¦é\u0099¢æ\u0096\u0087ç\u008C®æ\u0083\u0085æ\u008A¥ä¸\u00ADå¿\u0083;å\u009B½å®¶ç§\u0091å\u00AD¦å\u009B¾ä¹¦é¦\u0086j\u0003TP3j\u0003TG1\u0092\u0001\få\u009B¾å\u0083\u008Fæ£\u0080ç´¢\u0092\u0001\fæ£\u0080ç´¢æ\u008A\u0080æ\u009C¯\u0092\u0001\u0012å\u009B¾å\u0083\u008Fä¿¡æ\u0081¯æ£\u0080ç´¢\u0092\u0001\fç\u0093¶é¢\u0088é\u0097®é¢\u0098\u0092\u0001\fæ\u008A\u0080æ\u009C¯å\u008F\u0091å±\u0095\u0092\u0001\u0006å\u0088¶çº¦\u0092\u0001\u0006å\u008E\u009Fç\u0090\u0086\u0092\u0001\u0006ç³»ç»\u009F\u0092\u0001\u0006è¯\u0084ä»·\u0092\u0001\u0006å\u009Fºç¡\u0080\u0092\u0001\u0006é\u0098\u0090é\u0087\u008Aâ\u0001\u00132002-01-01 00:00:00ê\u0001\u00132005-11-03 00:00:00ò\u0001\u00132005-11-03 00:00:00¢\u0002\u000570-73²\u0002\u0015ç½\u0091ç»\u009Cå¤\u009Aåª\u0092ä½\u0093æ\u008A\u0080æ\u009C¯ò\u0002\n" +
            "11-2856/G2ø\u0002\u0016À\u0003\u0002Ê\u0003\u0003G25Ò\u0003\u0012a0028312030:ç\u008E\u008Bæ¬£Ý\u0003í\u0003¯\u0094Ý?ð\u0003d\u0090\u0004\u009A\u0004\u00132021-09-09 00:00:00¥\u0004pB\u00AD\u0004HB\"\u0083\u000B\n" +
            "\n" +
            "Periodical\u0012\u0004\b\u0001\u0010\u0001\u0012\u0004\b\u0006\u0010\u0001\u001ALChlQZXJpb2RpY2FsQ0hJTmV3UzIwMjExMDI2Eg14ZHFiMjAwMjA2MDUxGghwaGF4eW9lMQ%3D%3Dª\u0006\u0099\n";
    String s_utf8 = new String(str.getBytes("ISO8859-1"),"UTF-8");
    System.out.println(s_utf8);*/




    /** HtmlUnit请求web页面 */
    // 模拟chorme浏览器，其他浏览器请修改BrowserVersion.后面
  /* WebClient wc =  new  WebClient(BrowserVersion.CHROME);
    wc.getOptions().setUseInsecureSSL(true);
    wc.getOptions().setJavaScriptEnabled( true );  // 启用JS解释器，默认为true
    wc.getOptions().setCssEnabled( false );  // 禁用css支持
    wc.getOptions().setThrowExceptionOnScriptError( false );  // js运行错误时，是否抛出异常
    wc.getOptions().setTimeout( 10000 );  // 设置连接超时时间 ，这里是10S。如果为0，则无限期等待
    HtmlPage page = wc.getPage( "https://www.sciencedirect.com/search?qs=aa&offset=25" );
   System.out.println("输出：："+ page.asXml());
    Thread.sleep(1000);*/


    //String  pageXml = page.asXml();  // 以xml的形式获取响应文本
    // text只会获取里面的文本,网页html标签和script脚本会被去掉
    //System.out.println(page.getPage());
    //System.out.println(page.asText());
    System.out.println("fffff");

    /*WebClient webClient = new WebClient(BrowserVersion.FIREFOX_38);
    //设置webClient的相关参数
    webClient.getOptions().setJavaScriptEnabled(true);
    webClient.getOptions().setCssEnabled(false);
    webClient.setAjaxController(new NicelyResynchronizingAjaxController());
    webClient.getOptions().setUseInsecureSSL(true);
    //webClient.getOptions().setTimeout(50000);
    //webClient.getOptions().setThrowExceptionOnScriptError(false);
    //模拟浏览器打开一个目标网址
    HtmlPage rootPage = webClient.getPage("http://s.wanfangdata.com.cn/paper?q=www&p=2");
    System.out.println("为了获取js执行的数据 线程开始沉睡等待");
    Thread.sleep(3000);//主要是这个线程的等待 因为js加载也是需要时间的
    System.out.println("线程结束沉睡");
    String html = rootPage.asText();
    System.out.println(html);*/


   /* HtmlUnitDriver unitDriver = new HtmlUnitDriver();

    unitDriver.get("https://s.wanfangdata.com.cn/paper?q=www&p=2");

    System.out.println("Title of the page is:" +unitDriver.findElement(By.className("right-list")));

      WebDriver dr = new HtmlUnitDriver();
    dr.get("https://s.wanfangdata.com.cn/paper?q=www&p=2");
    Thread.sleep(5000);
    System.out.println("page title is:"+dr.findElement(By.className("right-list")));*/
      /*PhantomJSDriver newDriver = Driver.getDriver();

      newDriver.get("https://s.wanfangdata.com.cn/paper?q=www&p=2");

      try {
          Thread.sleep(1000L);
      } catch (InterruptedException e) {
          e.printStackTrace();
      }
      //InfoJson
      JSONObject newinfoobject = new JSONObject();
      //infoJsonObject.put("detail", newinfoobject);
      System.out.println(newDriver.getPageSource());*/
      //Duration duration = Duration.;
      /*WebDriver driver = new FirefoxDriver();
      WebDriverWait wait = new WebDriverWait(driver, 10);
      try {
          driver.get("https://s.wanfangdata.com.cn/paper?q=www&p=2");
          //driver.findElement(By.name("q")).sendKeys("cheese" + Keys.ENTER);
          //WebElement firstResult = wait.until(presenceOfElementLocated(By.cssSelector("h3")));
          System.out.println(driver.findElement(By.className("right-list")));
      } finally {
          driver.quit();
      }*/
  }
}
